package com.fxpc.hddc.activefault.jpa.dao.primary;


import com.fxpc.hddc.activefault.dto.pg.entity.HddcActivefaultPgEntity;
import com.fxpc.hddc.activefault.dto.primary.entity.HddcActivefaultEntity;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;


/**
 * @author zyb
 * @date 2020-11-30
 */
@Repository
public interface HddcActivefaultBaseDao extends JpaRepository<HddcActivefaultEntity, String> {

    @Query(nativeQuery = true, value = "select * from hddc_activefault where SUBSTRING(create_time,1,10)= :nowDay AND is_valid = 1")
    List<HddcActivefaultEntity> findOneDayDataByCreateTime(@Param(value = "nowDay") LocalDate nowDay);

    @Query(nativeQuery = true, value = "select * from hddc_activefault where is_valid = 1")
    List<HddcActivefaultEntity> findAllTime();

    Long count(Specification<HddcActivefaultEntity> specification);


    List<HddcActivefaultEntity> findAll(Specification<HddcActivefaultEntity> specification);


}
